package com.service.impl;

import com.bean.News;
import com.dao.NewsMapper;
import com.service.NewsService;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;

public class NewsServiceImpl implements NewsService {

    private NewsMapper newsMapper;

    @Override
    public void publish(News news) {// 业务方法，打开一次数据库，提交事务后，关闭
        news.setState(1);         //状态
        news.setPubtime(new Date());//时间
        news.setIsElite(0);
        System.out.println("问题问题问题:::3");
        newsMapper.add(news);
        System.out.println("问题问题问题:::4");// 问题
        //解决
    }
    @Override
    public void edit(News news) {}
    @Override
    public void approve(News news) {}
    @Override
    public News get(int id) {
        return newsMapper.findNewsWithReplys(id);
    }
    @Override
    public List<News> list(Map<String, Object> params) {
        return null;
    }
    //get set 方法配置文件的property 可以识别
    public NewsMapper getNewsMapper() {
        return newsMapper;
    }
    public void setNewsMapper(NewsMapper newsMapper) {
        this.newsMapper = newsMapper;
    }
}
